<include file="Public:header" />
<table id="DataGrid">
    <thead>

    </thead>
</table>
<div id="Toolbar">
    <fieldset>
        <legend>搜索</legend>
        <div class="form-panel">
            姓名：<input name="RealName" size="15" class="input-text">
            角色：{:W('Combobox', array('table' => 'role', 'name' => 'role_id', 'idField' => 'role_id', 'valField' => 'role_name', 'style' => 'width:150px;'))}
            <a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-search" onclick="searchItem()"> 搜索 </a>
        </div>
    </fieldset>
    <a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-add" plain="true" onclick="addUser()">添加</a>
    <a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-edit" plain="true" onclick="editUser()">编辑</a>
    <a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-lock" plain="true" onclick="lockUser()">锁定</a>
    <a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-print" plain="true" onclick="openLog()">查看操作日志</a>
</div>
<script type="text/javascript">
    var MasterGrid = $('#DataGrid');
    $(function(){
        var sexData = [{sexname: '男',sex: '1'},{sexname: '女',sex: '2'}];
        MasterGrid.datagrid({
            url: "{:U('master/index')}",
            fit:true,
            border:false,
            onClickCell: function(index, field){
                MasterGrid.datagrid('editGrid', {type:'cell', index:index, field:field});
            },
            toolbar: "#Toolbar",
            pagination: true,
            fitColumns: true,
            columns:[[
                {field:'ck',checkbox:true},
                {field:'user_id',title:'编号',width:50, sortable: true},
                {field:'user_name',title:'登录账号',width:120},
                {field:'real_name',title:'真实姓名',width:120, editor:'text'},
                {field:'sex',title:'性别',width:50, formatter:function(value){
                    for(var i = 0; i < sexData.length; i++){
                        if (sexData[i].sex == value) return sexData[i].sexname;
                    }
                    return value;
                }},
                {field:'locked',title:'禁止登录',width: 50, align:'center', formatter:function(value){
                    return value == 1 ? '是' : '否';
                }},
                {field:'create_date',title:'添加时间',width:120},
                {field:'role_ids',title:'所属组别'}
            ]]
        });
    })

    function addUser(){
        sysbase.dialog({
            title: '添加管理员',
            width: 800,
            height: 450,
            href: "{:U('master/form')}",
            handler: function(){
                MasterGrid.datagrid('reload');
            }
        });
    }
</script>
<include file="Public:footer" />